﻿using System;
using System.Data;
using System.Text;
using Common;
using HCRS.DBACL;
using HCRS.Implementation;

namespace JinJiang.BookingEngine.Web.en
{
    public class H_ratelist
    {
        private DataAccessLayer _DataAccessLayer = new DataAccessLayer();
        private HotelClass _HotelClass = new HotelClass();
        private CommonWeb _CommonClass = new CommonWeb();

        private string[] Day = new[]
                                   {
                                       "Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"
                                   };

        private string[] DayCN = new[]
                                     {
                                         "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"
                                     };

        public string GetRate(DataSet dtRate, int hotelID, string checkIN, string checkOUT, int nights, string room, string adult, string child)
        {
            var GetRateString = new StringBuilder();
            if (dtRate != null && dtRate.Tables[0] != null && dtRate.Tables[1] != null)
            {
                for (var j = 0; j < dtRate.Tables[0].Rows.Count; j++) //generate all rate table
                {
                    var rowRate = dtRate.Tables[1].Select(" plancode = '" + dtRate.Tables[0].Rows[j]["plancode"] + "'  ");
                    var datecell = Convert.ToDateTime(checkIN);
                    var k = 0;
                    var showUrl = true;
                    decimal totalrevenue = 0;
                    var wC = Convert.ToDouble(nights) / 7.0;
                    var weekCount = Convert.ToInt32(Math.Ceiling(wC));


                    GetRateString.Append("<span class=font_bold>&nbsp;&nbsp;&nbsp;&nbsp;" + dtRate.Tables[0].Rows[j]["roomname"] + "-" + dtRate.Tables[0].Rows[j]["ratename"] + "</span><br/>");
                    GetRateString.Append("<table class=table_rate>");
                    GetRateString.Append("<tr align=center>");
                    GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>Week</td>");
                    GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
                    GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
                    GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
                    GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
                    GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
                    GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
                    GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");


                    for (var i = 0; i < weekCount; i++) // generate rate content by week
                    {
                        GetRateString.Append("<tr align=center>");
                        //GetRateString.Append("<td height=20 >"+ _CommonClass.getNumber((i + 1).ToString())+" Week:</td>");
                        GetRateString.Append("<td height=20 >" + (i + 1).ToString() + " </td>");
                        for (var l = 0; l < 7; l++)
                        {
                            if (k >= rowRate.Length)
                            {
                                GetRateString.Append("<td class=tdbackcolorgrey></td>");
                            }
                            else if (Convert.ToDateTime(rowRate[k]["availdate"]) == datecell.AddDays(l + 7 * i)) //如果和表格里的日期相符，则显示价格，否则进入下一个表格
                            {
                                //GetRateString.Append("<td height=20 >" + rowRate[k]["priceNoTax"] + "</td>";

                                if (rowRate[k]["avstat"].ToString() == "B") //如果是ALLOTMENT<person 显示紧张
                                    //如果是minlos>nights> maxlos   显示入住限制，最大入住和最小入住
                                {
                                    GetRateString.Append("<td  class=tdbackcolorgrey >");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                        GetRateString.Append("</td>");
                                    }
                                }
                                else if (i == 0 && rowRate[k]["avstat"].ToString() == "C")
                                    //如果是minlos>nights> maxlos   显示入住限制，最大入住和最小入住
                                {
                                    GetRateString.Append("<td  class=tdbackcolorgrey >");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else if (rowRate[k]["avstat"].ToString() == "L" && (Convert.ToInt32(rowRate[k]["maxLos"].ToString()) < nights || Convert.ToInt32(rowRate[k]["minLos"].ToString()) > nights)) //如果是ALLOTMENT<person 显示紧张
                                    //如果是minlos>nights> maxlos   显示入住限制，最大入住和最小入住
                                {
                                    GetRateString.Append("<td  class=tdbackcolorgrey >");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else if (Convert.ToInt32(rowRate[k]["Allotment"]) > 0) //如果有可用房，显示正常颜色
                                {
                                    GetRateString.Append("<td  class=tdbackcolorgrey>");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(_CommonClass.getMonthDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString());
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else //如果是ALLOTMENT<person 显示紧张
                                {
                                    GetRateString.Append("<td class=tdbackcolorgrey >");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(_CommonClass.getDate(rowRate[k]["AvailDate"].ToString()));
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                k++;
                            }
                            else
                            {
                                GetRateString.Append("<td class=tdbackcolorgrey >-" + rowRate[k]["availdate"] + "</td>"); //2007.12.25 andy NA修改为-
                            }
                        }
                        GetRateString.Append("</tr>");
                    }
                    GetRateString.Append("<tr >");
                    GetRateString.Append("<td height=20 colspan=\"7\" class=tdborder>");
                    GetRateString.Append("<UL>");


                    GetRateString.Append("<LI>" + string.Format("Total room(s) charge({0} night(s)) : {1}", nights, totalrevenue) + " CNY</LI>");
                    if (dtRate.Tables[0].Rows[j]["roomdesc"] != null && dtRate.Tables[0].Rows[j]["roomdesc"].ToString() != "")
                    {
                        GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["roomdesc"] + "</LI>");
                    }
                    if (dtRate.Tables[0].Rows[j]["plandesc"] != null && dtRate.Tables[0].Rows[j]["plandesc"].ToString() != "")
                    {
                        GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["plandesc"] + "</LI>");
                    }
                    if (dtRate.Tables[1].Rows[0]["extraadult"] != null && dtRate.Tables[1].Rows[0]["extraadult"].ToString() != "")
                    {
                        GetRateString.Append("<LI>Extra Bed: " + Convert.ToDecimal(dtRate.Tables[1].Rows[0]["extraadult"].ToString()) + "CNY/Bed/Night</LI>");
                    }
                    GetRateString.Append("</UL>");
                    GetRateString.Append("</td>");
                    GetRateString.Append("<td class=tdborder><div align=center>");

                    if (showUrl)
                    {
                        var url = "";
                        url += "<a  href=\"Reservation.aspx?HotelID=" + hotelID + "&RoomCode=" + dtRate.Tables[0].Rows[j]["roomcode"] + "&RateCode=" + dtRate.Tables[0].Rows[j]["ratecode"] + "&ChkIN=" + checkIN + "&ChkOUT=" + checkOUT + "&Rooms=" + room + "&Adult=" + adult + "&Child=" + child + "\" > Book it </a>";
                        GetRateString.Append(url);
                    }
                    else
                    {
                        GetRateString.Append("-"); //2007.12.25 andy NA修改为-
                    }
                    GetRateString.Append("</div></td>");
                    GetRateString.Append("</tr> </table>");
                    GetRateString.Append("<br /><br /><br />");
                }
            }
            else
            {
                GetRateString.Append("no rate data available");
            }

            return GetRateString.ToString();
        }

        /**/

        /// <summary>
        /// 	从XML接口类生成的dataset中读取房价和房型描述信息，显示每周价格表格和相关房型、价格描述
        /// </summary>
        /// <param name="dtRate"> 调用xml返回的dataset，价格表＋描述表 </param>
        /// <param name="hotelID"> hotelID 暂无用 </param>
        /// <param name="checkIN"> 入住日期 </param>
        /// <param name="checkOUT"> 离店日期 暂无用 </param>
        /// <param name="nights"> int nights 房夜数 </param>
        /// <param name="room"> int room </param>
        /// <param name="adult"> int adult 暂无用 </param>
        /// <param name="child"> int child 暂无用 </param>
        /// <param name="url"> string url url链接 </param>
        /// <param name="language"> language，0是中文，1是英文 </param>
        public string FIT_GetXMLRate(DataSet dtRate, int hotelID, string checkIN, string checkOUT, int nights, int room, int adult, int child, string url, int language)
        {
            var GetRateString = new StringBuilder();
            var tempCurrencyCode = "";
            if (dtRate != null && dtRate.Tables[0] != null && dtRate.Tables[1] != null)
            {
                for (var j = 0; j < dtRate.Tables[0].Rows.Count; j++) //generate all rate table
                {
                    var gua = dtRate.Tables[0].Rows[j]["resvGua"].ToString();

                    var rowRate = dtRate.Tables[1].Select(" plancode = '" + dtRate.Tables[0].Rows[j]["plancode"] + "' and gua<>'CP'  ");

                    if (rowRate.Length <= 0 || dtRate.Tables[0].Rows[j]["resvstatus"].ToString().ToUpper() != "A")
                    {
                        continue;
                    }

                    var datecell = Convert.ToDateTime(checkIN);
                    var k = 0;
                    var showUrl = true;
                    decimal totalrevenue = 0;
                    var wC = Convert.ToDouble(nights) / 7.0;
                    var weekCount = Convert.ToInt32(Math.Ceiling(wC));

                    var currentneights = nights;

                    GetRateString.Append("<span class=font_bold>&nbsp;&nbsp;&nbsp;&nbsp;" + dtRate.Tables[0].Rows[j]["roomname"] + "-" + dtRate.Tables[0].Rows[j]["ratename"] + "</span><br/>");
                    GetRateString.Append("<table class=table_rate>");
                    GetRateString.Append("<tr align=center>");

                    if (language == 0) //如果是0显示中文表头，否则显示英文
                    {
                        GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>周</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");
                    }
                    else
                    {
                        GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>Week</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");
                    }

                    for (var i = 0; i < weekCount; i++) // generate rate content by week
                    {
                        GetRateString.Append("<tr align=center>");
                        //GetRateString.Append("<td height=20 >"+ _CommonClass.getNumber((i + 1).ToString())+" Week:</td>");
                        GetRateString.Append("<td height=20 >" + (i + 1).ToString() + " </td>");
                        for (var l = 0; l < 7; l++)
                        {
                            if (k >= rowRate.Length)
                            {
                                GetRateString.Append("<td class=tdbackcolorgrey></td>");
                            }
                            else if (Convert.ToDateTime(rowRate[k]["availdate"]) == datecell.AddDays(l + 7 * i)) //如果和表格里的日期相符，则显示价格，否则进入下一个表格
                            {
                                tempCurrencyCode = rowRate[k]["CurrencyCode"].ToString();
                                var tempdate = Convert.ToDateTime(rowRate[k]["availdate"]);
                                var tempstr = "tdrateavailable";
                                //if (dtRate.Tables[0].Rows[j]["ratecode"].ToString() == "JJWKDB")
                                //{
                                //    if (tempdate.DayOfWeek == DayOfWeek.Friday || tempdate.DayOfWeek == DayOfWeek.Saturday || tempdate.DayOfWeek == DayOfWeek.Sunday)
                                //    {
                                //        tempstr = "tdbackcolorweek";
                                //    }
                                //}

                                string datename;
                                if (language == 0) //如果是0显示中文星期名称，否则英文
                                {
                                    datename = string.Format("{0:yy/MM/dd}", Convert.ToDateTime(rowRate[k]["availdate"]));
                                }
                                else
                                {
                                    datename = string.Format("{0:yy/MM/dd}", Convert.ToDateTime(rowRate[k]["availdate"]));
                                    datename = _CommonClass.getDate(datename); //格式化成英文月简称
                                }

                                if (rowRate[k]["avstat"].ToString() == "B") //如果是关房
                                {
                                    GetRateString.Append("<td  class=tdblockrate >");


                                    GetRateString.Append(datename);
                                    GetRateString.Append("<br/>");
                                    GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                    GetRateString.Append("</td>");
                                    showUrl = false;
                                }
                                else if (i == 0 && rowRate[k]["avstat"].ToString() == "C")
                                    //如果是minlos>nights> maxlos   显示入住限制，最大入住和最小入住
                                {
                                    if (tempstr == "tdbackcolorweek")
                                    {
                                        GetRateString.Append("<td  class=" + tempstr + " >");
                                    }
                                    else
                                    {
                                        GetRateString.Append("<td  class=tdbackcolorgrey >");
                                    }

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else if (rowRate[k]["avstat"].ToString() == "L" && (Convert.ToInt32(rowRate[k]["maxLos"].ToString()) < nights || Convert.ToInt32(rowRate[k]["minLos"].ToString()) > nights)) //如果是ALLOTMENT<person 显示紧张
                                    //如果是minlos>nights> maxlos   显示入住限制，最大入住和最小入住
                                {
                                    if (tempstr == "tdbackcolorweek")
                                    {
                                        GetRateString.Append("<td  class=" + tempstr + " >");
                                    }
                                    else
                                    {
                                        GetRateString.Append("<td  class=tdbackcolorgrey >");
                                    }

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else if (Convert.ToInt32(rowRate[k]["Allotment"]) > 0) //如果有可用房，显示正常颜色
                                {
                                    GetRateString.Append("<td  class=" + tempstr + ">");
                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString());
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else //如果是ALLOTMENT<person 显示紧张
                                {
                                    if (tempstr == "tdbackcolorweek")
                                    {
                                        GetRateString.Append("<td  class=" + tempstr + " >");
                                    }
                                    else
                                    {
                                        GetRateString.Append("<td class=tdbackcolorgrey >");
                                    }

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                k++;
                            }
                            else
                            {
                                GetRateString.Append("<td class=tdbackcolorgrey >" + datecell.AddDays(l + 7 * i).ToShortDateString() + "<br />-</td>"); //2007.12.25 andy NA修改为-
                                currentneights--;
                                showUrl = false;
                            }
                        }
                        GetRateString.Append("</tr>");
                    }
                    GetRateString.Append("<tr >");
                    GetRateString.Append("<td height=20 colspan=\"7\" class=tdborder>");
                    GetRateString.Append("<UL>");

                    if (language == 0)
                    {
                        GetRateString.Append("<LI>" + string.Format("总房价({0} 房夜) : {1}", currentneights, totalrevenue) + " " + tempCurrencyCode + "</LI>");
                        if (dtRate.Tables[0].Rows[j]["roomdesc"] != null && dtRate.Tables[0].Rows[j]["roomdesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["roomdesc"] + "</LI>");
                        }
                        if (dtRate.Tables[0].Rows[j]["plandesc"] != null && dtRate.Tables[0].Rows[j]["plandesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["plandesc"] + "</LI>");
                        }
                        if (rowRate[0]["extraadult"] != null && rowRate[0]["extraadult"].ToString() != "0.0")
                        {
                            GetRateString.Append("<LI>加床价： " + rowRate[0]["extraadult"] + " " + tempCurrencyCode + "/床/房夜</LI>");
                        }
                        GetRateString.Append("</UL>");
                        GetRateString.Append("</td>");
                        GetRateString.Append("<td class=tdborder><div align=center>");

                        if (showUrl)
                        {
                            var linkage = ""; //format出一个链接地址
                            //andy.修改为按钮图片.
                            linkage = "<a href=\"" + string.Format(url, hotelID, dtRate.Tables[0].Rows[j]["roomcode"], dtRate.Tables[0].Rows[j]["ratecode"], checkIN, checkOUT, room, adult, child) + "\" ><img src=\"images/booking.gif\" border=\"0\"/></a>";
                            GetRateString.Append(linkage);
                        }
                        else
                        {
                            GetRateString.Append("-"); //2007.12.25 andy NA修改为-
                        }
                    }
                    else
                    {
                        GetRateString.Append("<LI>" + string.Format("Total room(s) charge({0} night(s)) : {1}", nights, totalrevenue) + " " + tempCurrencyCode + "</LI>");
                        if (dtRate.Tables[0].Rows[j]["roomdesc"] != null && dtRate.Tables[0].Rows[j]["roomdesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["roomdesc"] + "</LI>");
                        }
                        if (dtRate.Tables[0].Rows[j]["plandesc"] != null && dtRate.Tables[0].Rows[j]["plandesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["plandesc"] + "</LI>");
                        }
                        if (rowRate[0]["extraadult"] != null && rowRate[0]["extraadult"].ToString() != "0.0")
                        {
                            GetRateString.Append("<LI>Extra Bed: " + rowRate[0]["extraadult"] + " " + tempCurrencyCode + "/Bed/Night</LI>");
                        }
                        GetRateString.Append("</UL>");
                        GetRateString.Append("</td>");
                        GetRateString.Append("<td class=tdborder><div align=center>");

                        if (showUrl)
                        {
                            var linkage = ""; //format出一个链接地址
                            linkage = "<a href=\"" + string.Format(url, hotelID, dtRate.Tables[0].Rows[j]["roomcode"], dtRate.Tables[0].Rows[j]["ratecode"], checkIN, checkOUT, room, adult, child) + "\" > Book it </a>";
                            GetRateString.Append(linkage);
                        }
                        else
                        {
                            GetRateString.Append("-");
                        }
                    }


                    GetRateString.Append("</div></td>");
                    GetRateString.Append("</tr> </table>");
                    GetRateString.Append("<br /><br /><br />");
                }
            }
            else
            {
                GetRateString.Append("no rate data available");
            }

            return GetRateString.ToString();
        }

        #region 预订引擎

        /**/

        /// <summary>
        /// 	从XML接口类生成的dataset中读取房价和房型描述信息，显示每周价格表格和相关房型、价格描述 预订引擎
        /// </summary>
        /// <param name="dtRate"> 调用xml返回的dataset，价格表＋描述表 </param>
        /// <param name="hotelID"> hotelID 暂无用 </param>
        /// <param name="checkIN"> 入住日期 </param>
        /// <param name="checkOUT"> 离店日期 暂无用 </param>
        /// <param name="nights"> int nights 房夜数 </param>
        /// <param name="room"> int room </param>
        /// <param name="adult"> int adult 暂无用 </param>
        /// <param name="child"> int child 暂无用 </param>
        /// <param name="url"> string url url链接 </param>
        /// <param name="language"> language，0是中文，1是英文 </param>
        public string FIT_GetXMLRate(DataSet dtRate, int hotelID, string checkIN, string checkOUT, int nights, int room, int adult, int child, string url, int userid, int language)
        {
            var GetRateString = new StringBuilder();
            if (dtRate != null && dtRate.Tables[0] != null && dtRate.Tables[1] != null)
            {
                for (var j = 0; j < dtRate.Tables[0].Rows.Count; j++) //generate all rate table
                {
                    var rowRate = dtRate.Tables[1].Select(" plancode = '" + dtRate.Tables[0].Rows[j]["plancode"] + "'  ");
                    var datecell = Convert.ToDateTime(checkIN);
                    var k = 0;
                    var showUrl = true;
                    decimal totalrevenue = 0;
                    var wC = Convert.ToDouble(nights) / 7.0;
                    var weekCount = Convert.ToInt32(Math.Ceiling(wC));


                    GetRateString.Append("<span class=font_bold>&nbsp;&nbsp;&nbsp;&nbsp;" + dtRate.Tables[0].Rows[j]["roomname"] + "-" + dtRate.Tables[0].Rows[j]["ratename"] + "</span><br/>");
                    GetRateString.Append("<table class=table_rate>");
                    GetRateString.Append("<tr align=center>");

                    if (language == 0) //如果是0显示中文表头，否则显示英文
                    {
                        GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>周</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");
                    }
                    else
                    {
                        GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>Week</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
                        GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");
                    }

                    for (var i = 0; i < weekCount; i++) // generate rate content by week
                    {
                        GetRateString.Append("<tr align=center>");
                        //GetRateString.Append("<td height=20 >"+ _CommonClass.getNumber((i + 1).ToString())+" Week:</td>");
                        GetRateString.Append("<td height=20 >" + (i + 1).ToString() + " </td>");
                        for (var l = 0; l < 7; l++)
                        {
                            if (k >= rowRate.Length)
                            {
                                GetRateString.Append("<td class=tdbackcolorgrey></td>");
                            }
                            else if (Convert.ToDateTime(rowRate[k]["availdate"]) == datecell.AddDays(l + 7 * i)) //如果和表格里的日期相符，则显示价格，否则进入下一个表格
                            {
                                string datename;
                                if (language == 0) //如果是0显示中文星期名称，否则英文
                                {
                                    datename = string.Format("{0:yy/MM/dd}", Convert.ToDateTime(rowRate[k]["availdate"]));
                                }
                                else
                                {
                                    datename = string.Format("{0:yy/MM/dd}", Convert.ToDateTime(rowRate[k]["availdate"]));
                                    datename = _CommonClass.getDate(datename); //格式化成英文月简称
                                }

                                if (rowRate[k]["avstat"].ToString() == "B") //如果是关房
                                {
                                    GetRateString.Append("<td  class=tdblockrate >");


                                    GetRateString.Append(datename);
                                    GetRateString.Append("<br/>");
                                    GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                    GetRateString.Append("</td>");
                                    showUrl = false;
                                }
                                else if (i == 0 && rowRate[k]["avstat"].ToString() == "C")
                                    //如果是minlos>nights> maxlos   显示入住限制，最大入住和最小入住
                                {
                                    GetRateString.Append("<td  class=tdbackcolorgrey >");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else if (rowRate[k]["avstat"].ToString() == "L" && (Convert.ToInt32(rowRate[k]["maxLos"].ToString()) < nights || Convert.ToInt32(rowRate[k]["minLos"].ToString()) > nights)) //如果是ALLOTMENT<person 显示紧张
                                    //如果是minlos>nights> maxlos   显示入住限制，最大入住和最小入住
                                {
                                    GetRateString.Append("<td  class=tdbackcolorgrey >");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else if (Convert.ToInt32(rowRate[k]["Allotment"]) > 0) //如果有可用房，显示正常颜色
                                {
                                    GetRateString.Append("<td  class=tdrateavailable>");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString());
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                else //如果是ALLOTMENT<person 显示紧张
                                {
                                    GetRateString.Append("<td class=tdbackcolorgrey >");

                                    if (rowRate[k]["priceNoTax"].ToString() == null)
                                    {
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append("<font color=red>-</font>"); //2007.12.25 andy NA修改为-
                                        GetRateString.Append("</td>");
                                        showUrl = false;
                                    }
                                    else
                                    {
                                        GetRateString.Append(FGBCommon.GetGuaImage(rowRate[k]["gua"].ToString()));
                                        GetRateString.Append(datename);
                                        GetRateString.Append("<br/>");
                                        GetRateString.Append(rowRate[k]["priceNoTax"].ToString().Replace(".00", ""));
                                        GetRateString.Append("</td>");
                                        totalrevenue += (decimal.Round(Convert.ToDecimal(rowRate[k]["priceNoTax"].ToString()), 2) * Convert.ToInt32(room));
                                    }
                                }
                                k++;
                            }
                            else
                            {
                                GetRateString.Append("<td class=tdbackcolorgrey >-" + rowRate[k]["availdate"] + "</td>"); //2007.12.25 andy NA修改为-
                            }
                        }
                        GetRateString.Append("</tr>");
                    }
                    GetRateString.Append("<tr >");
                    GetRateString.Append("<td height=20 colspan=\"7\" class=tdborder>");
                    GetRateString.Append("<UL>");

                    if (language == 0)
                    {
                        GetRateString.Append("<LI>" + string.Format("总房价({0} 房夜) : {1}", nights, totalrevenue) + " CNY</LI>");
                        if (dtRate.Tables[0].Rows[j]["roomdesc"] != null && dtRate.Tables[0].Rows[j]["roomdesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["roomdesc"] + "</LI>");
                        }
                        if (dtRate.Tables[0].Rows[j]["plandesc"] != null && dtRate.Tables[0].Rows[j]["plandesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["plandesc"] + "</LI>");
                        }
                        if (rowRate[0]["extraadult"] != null && rowRate[0]["extraadult"].ToString() != "0.0")
                        {
                            GetRateString.Append("<LI>加床价： " + rowRate[0]["extraadult"] + " CNY/床/房夜</LI>");
                        }
                        GetRateString.Append("</UL>");
                        GetRateString.Append("</td>");
                        GetRateString.Append("<td class=tdborder><div align=center>");

                        if (showUrl)
                        {
                            var linkage = ""; //format出一个链接地址
                            //andy.修改为按钮图片.
                            linkage = "<a href=\"" + string.Format(url, hotelID, dtRate.Tables[0].Rows[j]["roomcode"], dtRate.Tables[0].Rows[j]["ratecode"], checkIN, checkOUT, room, adult, child, userid) + "\" >&gt;&gt;预订</a>";
                            GetRateString.Append(linkage);
                        }
                        else
                        {
                            GetRateString.Append("-"); //2007.12.25 andy NA修改为-
                        }
                    }
                    else
                    {
                        GetRateString.Append("<LI>" + string.Format("Total room(s) charge({0} night(s)) : {1}", nights, totalrevenue) + " CNY</LI>");
                        if (dtRate.Tables[0].Rows[j]["roomdesc"] != null && dtRate.Tables[0].Rows[j]["roomdesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["roomdesc"] + "</LI>");
                        }
                        if (dtRate.Tables[0].Rows[j]["plandesc"] != null && dtRate.Tables[0].Rows[j]["plandesc"].ToString() != "")
                        {
                            GetRateString.Append("<LI>" + dtRate.Tables[0].Rows[j]["plandesc"] + "</LI>");
                        }
                        if (rowRate[0]["extraadult"] != null && rowRate[0]["extraadult"].ToString() != "0.0")
                        {
                            GetRateString.Append("<LI>Extra Bed: " + rowRate[0]["extraadult"] + " CNY/Bed/Night</LI>");
                        }
                        GetRateString.Append("</UL>");
                        GetRateString.Append("</td>");
                        GetRateString.Append("<td class=tdborder><div align=center>");

                        if (showUrl)
                        {
                            var linkage = ""; //format出一个链接地址
                            linkage = "<a href=\"" + string.Format(url, hotelID, dtRate.Tables[0].Rows[j]["roomcode"], dtRate.Tables[0].Rows[j]["ratecode"], checkIN, checkOUT, room, adult, child, userid) + "\" > Book it </a>";
                            GetRateString.Append(linkage);
                        }
                        else
                        {
                            GetRateString.Append("-");
                        }
                    }


                    GetRateString.Append("</div></td>");
                    GetRateString.Append("</tr> </table>");
                    GetRateString.Append("<br /><br /><br />");
                }
            }
            else
            {
                GetRateString.Append("no rate data available");
            }

            return GetRateString.ToString();
        }

        #endregion

        public string GetRate(DataTable dailyPrice, string Chickindate, string Chickoutdate, int nights)
        {
            var datecell = Convert.ToDateTime(Chickindate);
            var k = 0;
            var wC = Convert.ToDouble(nights) / 7.0;
            var weekCount = Convert.ToInt32(Math.Ceiling(wC));
            var GetRateString = new StringBuilder();
            GetRateString.Append("<table class=table_rate>");
            GetRateString.Append("<tr align=center>");
            GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>Week</td>");
            GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
            GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
            GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
            GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
            GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
            GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
            GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");

            for (var i = 0; i < weekCount; i++)
            {
                GetRateString.Append("<tr align=center>");
                //GetRateString.Append("<td height=20 >" + _CommonClass.getNumber((i + 1).ToString()) + " Week:</td>");
                GetRateString.Append("<td height=20 >" + (i + 1).ToString() + "</td>");
                for (var l = 0; l < 7; l++)
                {
                    if (k >= dailyPrice.Rows.Count)
                    {
                        GetRateString.Append("<td class=tdbackcolorgrey></td>");
                    }
                    else
                    {
                        if (Convert.ToDateTime(dailyPrice.Rows[k]["AvailDate"].ToString()) == datecell.AddDays(l + 7 * i)) //如果和表格里的日期相符，则显示价格，否则进入下一个表格
                        {
                            GetRateString.Append("<td  class=tdbackcolorgrey >");
                            GetRateString.Append(_CommonClass.getMonthDate(dailyPrice.Rows[k]["AvailDate"].ToString()));
                            GetRateString.Append("<br/>");
                            GetRateString.Append(dailyPrice.Rows[k]["priceNoTax"].ToString());
                            GetRateString.Append("<br/>");
                            GetRateString.Append(dailyPrice.Rows[k]["Gua"].ToString());
                            GetRateString.Append("</td>");
                        }
                        k++;
                    }
                }
                GetRateString.Append("</tr>");
            }
            GetRateString.Append("</table>");
            return GetRateString.ToString();
        }

        /**/

        /// <summary>
        /// 	显示每周价格表格，
        /// </summary>
        /// <param name="dailyPrice"> 价格表 </param>
        /// <param name="Chickindate"> 入住日期 </param>
        /// <param name="Chickoutdate"> 离店日期 </param>
        /// <param name="nights"> 房夜数 </param>
        public string FIT_GetRate(DataTable dailyPrice, string Chickindate, string Chickoutdate, int nights, int language)
        {
            var datecell = Convert.ToDateTime(Chickindate);
            var k = 0;
            var wC = Convert.ToDouble(nights) / 7.0;
            var weekCount = Convert.ToInt32(Math.Ceiling(wC));
            var GetRateString = new StringBuilder();
            GetRateString.Append("<table class=table_rate>");
            GetRateString.Append("<tr align=center>");

            if (language == 0) //如果是0显示中文表头，否则显示英文
            {
                GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>周</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + DayCN[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");
            }
            else
            {
                GetRateString.Append("<td  class=tdbackcolorhead height=20 width=9%>Week</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(0).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(1).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(2).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(3).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(4).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(5).DayOfWeek)] + "</td>");
                GetRateString.Append("<td  class=tdbackcolorhead width=13%>" + Day[Convert.ToInt32(datecell.AddDays(6).DayOfWeek)] + "</td></tr>");
            }
            for (var i = 0; i < weekCount; i++)
            {
                GetRateString.Append("<tr align=center>");
                //GetRateString.Append("<td height=20 >" + _CommonClass.getNumber((i + 1).ToString()) + " Week:</td>");
                GetRateString.Append("<td height=20 >" + (i + 1).ToString() + "</td>");
                for (var l = 0; l < 7; l++)
                {
                    if (k >= dailyPrice.Rows.Count)
                    {
                        GetRateString.Append("<td class=tdbackcolorgrey></td>");
                    }
                    else
                    {
                        if (Convert.ToDateTime(dailyPrice.Rows[k]["AvailDate"].ToString()) == datecell.AddDays(l + 7 * i)) //如果和表格里的日期相符，则显示价格，否则进入下一个表格
                        {
                            string datename;
                            if (language == 0) //如果是0显示中文星期名称，否则英文
                            {
                                datename = string.Format("{0:yy/MM/dd}", Convert.ToDateTime(dailyPrice.Rows[k]["AvailDate"]));
                            }
                            else
                            {
                                datename = _CommonClass.getDate(dailyPrice.Rows[k]["AvailDate"].ToString());
                            }

                            GetRateString.Append("<td  class=tdbackcolorgrey >");
                            GetRateString.Append(datename);
                            GetRateString.Append("<br/>");
                            GetRateString.Append(dailyPrice.Rows[k]["priceNoTax"].ToString());
                            GetRateString.Append("<br/>");
                            GetRateString.Append(dailyPrice.Rows[k]["Gua"].ToString());
                            GetRateString.Append("</td>");
                        }
                        k++;
                    }
                }
                GetRateString.Append("</tr>");
            }
            GetRateString.Append("</table>");
            return GetRateString.ToString();
        }
    }
}